package cn.edu.sdjzu.xg.eagle.entity;

import lombok.*;

import java.io.Serializable;
import java.time.LocalDateTime;

//如果有双向关联，则不能@ToString，以避免递归引用
//@ToString
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class User implements Comparable<User>, Serializable {
    private Integer id;
    private String username;
    private String password;
    //关联的实际参与者对象，为Actor的某一个子类的对象
    private Actor actor;
    //记录关联的实际参与者，比如Teacher还是Student
    private ActorType actorType;
    //登录时间
    private LocalDateTime loginTime;

    public User(Integer id, String username, String password) {
        this(username, password);
        this.id = id;
    }

    public User(Integer id, String username, String password, ActorType actorType, Actor actor) {
        this(id, username, password);
        this.actorType = actorType;
        this.actor = actor;
    }

    public User(String username, String password) {
        this.username = username;
        this.password = password;
    }
    @Override
    public int compareTo(User o) {
        // TODO Auto-generated method stub
        return this.id - o.id;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
//                ", actor=" + actor.getName() +
                '}';
    }
}
